package com.binguo.api.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.binguo.api.alipay.util.PriceUtil;
import com.binguo.api.service.TecentYunTuService;
import com.binguo.model.api.vo.TecentVO;
import com.binguo.service.OrderService;
import com.tencentcloudapi.cbs.v20170312.models.Price;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

/**
 * @author yuritian
 * @Title: TecentYunPicController
 * @ProjectName binguoDevelop
 * @Description: TODO
 * @date 2020-01-1317:37
 */
@Api(tags = "腾讯云图")
@RestController
@RequestMapping
public class TecentYunPicController {

    @Autowired
    TecentYunTuService tecentYunTuService;


    @GetMapping(value = "/wxtestapi/api/tecentYunTu/getDayOrderCount/{type}", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "腾讯云图统计折线图", notes = "通过orderNo")
    public String getDayOrderCount(@PathVariable Integer type) {
        JSONArray result = new JSONArray();
        JSONObject value = new JSONObject();
        value.put("value",tecentYunTuService.getDayOrderCount(type));
        result.add(value);
        return result.toJSONString();
    }

    @GetMapping(value = "/wxtestapi/api/tecentYunTu/getDayOrderSum/{type}", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "腾讯云图统计折线图", notes = "通过orderNo")
    public String getDayOrderSum(@PathVariable Integer type) {
        JSONArray result = new JSONArray();
        JSONObject value = new JSONObject();
        value.put("value", PriceUtil.changeF2Y(tecentYunTuService.getDayOrderSum(type)));
        result.add(value);
        return result.toJSONString();
    }


    @GetMapping(value = "/wxtestapi/api/tecentYunTu/getHourSum", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "腾讯云图统计折线图", notes = "通过orderNo")
    public String getHourSum() {
        return tecentYunTuService.getHourSum().toJSONString();
    }

    @GetMapping(value = "/wxtestapi/api/tecentYunTu/getDaySum", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "腾讯云图近5日销售金额", notes = "通过orderNo")
    public String getDaySum() {
        return tecentYunTuService.getSumByDay().toJSONString();
    }

    @GetMapping(value = "/wxtestapi/api/tecentYunTu/getDaySourse", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "腾讯云图今日付款方式分布", notes = "通过orderNo")
    public String getDaySourse() {
        return tecentYunTuService.getSourceCount ().toJSONString();
    }
}
